﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using IBS.Bll;
using IBS.Bll.Accounts;
using IBS.Bll.Authority;
using IBS.Bll.AutoPayments;
using IBS.Bll.Bills;
using IBS.Bll.Cards;
using IBS.Bll.KnowledgeBase;
using IBS.Bll.Payments;
using IBS.Bll.Security;
using IBS.Bll.Transfers;
using IBS.Dal;
using IBS.ServiceContracts;

namespace ClientApp.Controllers
{
    public class BillController : Controller
    {
        private readonly IBillService _billService;
        private readonly ITransferService _transferService;

        public BillController()
        {
            var container = new IbsContainer();
            _transferService = container.TransferService;
            _billService = container.BillService;
        }

        //
        // GET: /Bill/

        public ActionResult GetBill(int transferId)
        {
            var transfer = _transferService.GetTransfers(t => t.Id == transferId).FirstOrDefault();
            var bill = _billService.GenerateBill(transfer);
            string billFileName = _billService.GetBill(bill);
            return File(billFileName, @"application/vnd.openxmlformats-officedocument.wordprocessingml.document");
        }

    }
}
